package com.xcl.controller;

import com.xcl.service.XclConsignerServiceInter;
import com.zzg.entity.Consigner;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @ClassName XclConsignerController
 * @Description 收货人控制器层
 * @Author: xiaochaolei
 * @date 2021/7/12 15:36
 * @Version 1. 0
 */
@Controller
public class XclConsignerController {
    @Autowired
    XclConsignerServiceInter xclConsignerServiceInter;

    /**
     * 新增收货人信息
     * @param consigner 收货人信息
     * @return 是否成功
     */
    @PostMapping(value = "/XclConsignerControllerInsertConsigner",produces = "application/text;charset=utf-8")
    @ResponseBody
    public String insertConsigner(Consigner consigner){
        xclConsignerServiceInter.insertConsigner(consigner);
        return "成功";
    }

    /**
     * 根据id查询收货人信息
     * @param id 收货人id
     * @return 收货人信息
     */
    @PostMapping(value = "/XclConsignerControllerGetConsignerById",produces = "application/json;charset=utf-8")
    @ResponseBody
    public Consigner getConsignerById(String id){
        Consigner consignerById = xclConsignerServiceInter.getConsignerById(id);
        return consignerById;
    }


    /**
     * 修改收货人信息
     * @param consigner 收货人信息
     * @return 是否成功
     */
    @PostMapping(value = "/XclConsignerControllerUpdateConsignerByid",produces = "application/text;charset=utf-8")
    @ResponseBody
    public String updateConsignerByid(Consigner consigner){
        xclConsignerServiceInter.updateConsignerByid(consigner);
        return "成功";
    }

    /**
     * 删除收货人信息
     * @param id 收货人信息
     * @return 是否成功
     */
    @PostMapping(value = "/XclConsignerControllerDeleteConsignerBy",produces = "application/text;charset=utf-8")
    @ResponseBody
    public String deleteConsignerBy(String id){
        if (xclConsignerServiceInter.deleteConsignerBy(id)>0){
            return "成功";
        }
        return "失败";
    }
}
